/**
 *   苹果手机操作系统 "iOS" *   安卓手机操作系统 "Android" *   微软手机操作系统 "Windows Phone" *   微软桌面操作系统 "Windows PC" *   苹果桌面操作系统 "Mac OS" *   未知操作系统 "Unknown"
 *   http://edn.egret.com/cn/docs/page/660
 */
class DeviceUtils extends BaseClass{
    
	public constructor() {
    	super();
	}

	private static isOS(os:string):boolean{
        return this.OS.indexOf(os) !=-1;
	}
	
    public static get isChineseLanguage():boolean{
        var language = this.getLanguage;
        if(language.indexOf("zh-CN") != -1 || language.indexOf("zh-TW") != -1 || language.indexOf("zh") != -1){
            return true;
        }else{
            return false;
        }
    }
    
    public static get isEnglish():boolean{
        var language = this.getLanguage;
        if(language.indexOf("en") != -1) {
            return true;
        } else {
            return false;
        }
    }
	
    public static get getLanguage():string{
        return egret.Capabilities.language;
    }
    
	public static get isIOS():boolean{
        return this.isOS("iOS");
	}
	
    public static get isAndroid(): boolean {
        return this.isOS("Android");
    }
	
    public static get isWindowsPhone(): boolean {
        return this.isOS("Windows Phone");
    }
	
    public static get isWindowsPC(): boolean {
        return this.isOS("Windows PC");
    }
    
    public static get isMacOS(): boolean {
        return this.isOS("Mac OS");
    }
    
	
    public static get OS():string{
        var os:string = egret.Capabilities.os;
        return os;
    }
	
    /**
     * 当前是否Html5版本
     * @returns {boolean}
     * @constructor
     */
    public static get isHtml5(): boolean {
        return egret.Capabilities.runtimeType == egret.RuntimeType.WEB;
    }

    /**
     * 当前是否是Native版本
     * @returns {boolean}
     * @constructor
     */
    public static get isNative(): boolean {
        return egret.Capabilities.runtimeType == egret.RuntimeType.NATIVE;
    }

    /**
     * 是否是在手机上
     * @returns {boolean}
     * @constructor
     */
    public static get isMobile(): boolean {
        return egret.Capabilities.isMobile;
    }

    /**
     * 是否是在PC上
     * @returns {boolean}
     * @constructor
     */
    public static get isPC(): boolean {
        return !egret.Capabilities.isMobile;
    }

    /**
     * 是否是QQ浏览器
     * @returns {boolean}
     * @constructor
     */
    public static get isQQBrowser(): boolean {
        return this.isHtml5 && navigator.userAgent.indexOf('MQQBrowser') != -1;
    }

    /**
     * 是否是IE浏览器
     * @returns {boolean}
     * @constructor
     */
    public static get isIEBrowser(): boolean {
        return this.isHtml5 && navigator.userAgent.indexOf("MSIE") != -1;
    }

    /**
     * 是否是Firefox浏览器
     * @returns {boolean}
     * @constructor
     */
    public static get isFirefoxBrowser(): boolean {
        return this.isHtml5 && navigator.userAgent.indexOf("Firefox") != -1;
    }

    /**
     * 是否是Chrome浏览器
     * @returns {boolean}
     * @constructor
     */
    public static get isChromeBrowser(): boolean {
        return this.isHtml5 && navigator.userAgent.indexOf("Chrome") != -1;
    }

    /**
     * 是否是Safari浏览器
     * @returns {boolean}
     * @constructor
     */
    public static get isSafariBrowser(): boolean {
        return this.isHtml5 && navigator.userAgent.indexOf("Safari") != -1;
    }

    /**
     * 是否是Opera浏览器
     * @returns {boolean}
     * @constructor
     */
    public static get isOperaBrowser(): boolean {
        return this.isHtml5 && navigator.userAgent.indexOf("Opera") != -1;
    }
	
    /**
     * test
     */ 
	public static test():void{
        Log.d("Language:"+this.getLanguage);  
        Log.d("isChromeBrowser:" + this.isChromeBrowser);  
        Log.d("isPC:" + this.isPC);  
        Log.d("isHtml5:" + this.isHtml5);  
        Log.d("OS:" + this.OS);  
	}
}
